#!/bin/bash

# 【安装 Hokuyo 驱动】
sudo apt install -y ros-noetic-urg-node

# 【安装MapTools导航插件】
cd ~/catkin_ws/src
git clone https://gitee.com/s-robot/waterplus_map_tools.git

# 【安装启程3源代码】
cd ~/catkin_ws/src/
git clone https://gitee.com/s-robot/wpv3.git
cd  wpv3/wpv3_bringup/scripts/
chmod +x create_udev_rules.sh
./create_udev_rules.sh
sudo apt install -y ros-noetic-joint-state-publisher-gui
sudo apt install -y ros-noetic-joy
sudo apt install -y ros-noetic-hector-mapping
sudo apt install -y ros-noetic-gmapping
sudo apt install -y ros-noetic-navigation
sudo apt install -y ros-noetic-cv-bridge
sudo apt install -y ros-noetic-audio-common
sudo apt install -y ros-noetic-controller-manager

# 【安装Kinect2 驱动】
# 1 下载源码
mkdir -p ~/Work/
cd ~/Work/
git clone https://gitee.com/s-robot/libfreenect2.git
cd libfreenect2

# 2 安装编译工具和依赖项
sudo apt install -y build-essential cmake pkg-config
sudo apt install -y libusb-1.0-0-dev
sudo apt install -y libturbojpeg0-dev
sudo apt install -y libglfw3-dev
sudo apt install -y libopenni2-dev

#3 编译
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -DENABLE_CXX11=ON
make
make install

#4 安装ROS驱动
sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
cd ~/catkin_ws/src/
git clone https://gitee.com/s-robot/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .

#5 编译ROS包
cd ~/catkin_ws
catkin_make

